package com.example.myapplication

import com.fasterxml.jackson.core.JsonParser
import org.json.JSONObject
import org.json.JSONStringer

/**
 * @author Quinn
 * @date 2022/9/12
 * @Desc
 */
class CreateNewPurseViewModel /*: ViewModel() */ {


    fun checkPwdStrong(pwd: String): Boolean {
        val toCharArray = pwd.toCharArray()
        val firstElement = toCharArray[0]
        var isAllEqual = true
        var isUp = true
        var isDown = true
        var upPreElement = firstElement
        var downPreElement = firstElement
        for (index in 1 until toCharArray.size) {
            if (isAllEqual) {
                isAllEqual = toCharArray[index] == firstElement
            }
            if (isUp) {
                isUp = toCharArray[index] - upPreElement == 1
                upPreElement = toCharArray[index]
            }
            if (isDown) {
                isDown = downPreElement - toCharArray[index] == 1
                downPreElement = toCharArray[index]
            }
        }
        return isAllEqual || isUp || isDown
    }

}

fun main() {
//    val model = CreateNewPurseViewModel()
//    println(model.checkPwdStrong("111111"))
//    println(model.checkPwdStrong("123456"))
//    println(model.checkPwdStrong("654321"))
}